import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/EatHutch/login.vue'
import EatHutchHome from '@/views/EatHutch/EatHutch.vue'
import BaiduMap from '@/views/EatHutch/Map.vue'
import Message from '@/views/EatHutch/Message.vue'
import Message2 from '@/views/EatHutch/Message2.vue'
import TrackThePlayback from '@/views/EatHutch/TrackThePlayback.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Login
  }, {
    path: '/hutchhome',
    component: EatHutchHome,
    children: [
      { path: '/map', component: BaiduMap },
      { path: '/dataD', component: Message2 },
      { path: '/dataC', component: Message }
    ]
  }, {
    path: '/playback/:VID',
    name: 'playback',
    component: TrackThePlayback
    // meta:{title: '餐厨'}
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})
// router.beforeEach((to, from, next) => {
//   let islogin = localStorage.getItem('islogin')
//   islogin = Boolean(Number(islogin))
//   if (islogin) {
//     next('/map')
//   }
// })
// router.beforeEach((to, from, next) => {
//   let islogin = localStorage.getItem('islogin')
//   islogin = Boolean(Number(islogin))
//   if (to.path === '/') {
//     if (islogin) {
//       next('/map')
//     } else {
//       next('/')
//     }
//   } else {
//     // if (to.meta.requireAuth && islogin) {
//     //   next()
//     // } else {
//     //   next('/login')
//     // }
//   }
// })
export default router
